import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Ap0stoL2
 * Date: 2023-07-30
 * Time: 21:35
 */


//线程池
public class Demo23 {
    public static void main(String[] args) {
        //ExecutorService为线程池对象
        //Executors 称为工厂类
        //newFixedThreadPool 为工厂方法
        //这里涉及到工厂模式--对标单例模式
        ExecutorService pool = Executors.newFixedThreadPool(10);

        for (int i = 0; i < 1000; i++) {
            pool.submit(new Runnable() {
                @Override
                public void run() {
                    System.out.println("hello");
                }
            });
        }
    }
}
